import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * 查询
 * @param query
 * @returns {*}
 */
export const getGategoryList = (query: CategoryList): AxiosPromise<CategoryList[]> => {
  return request({
    url: '/mall/menu/navList',
    params: query,
    method: 'get'
  });
};

export const getHomeList = (): AxiosPromise<CategoryList[]> => {
  return request({
    url: '/mall/menu/menuList',
    method: 'get'
  });
};

export const getNewGoodList = (): AxiosPromise<GoodsItem[]> => {
  return request({
    url: '/mall/menu/goodList',
    method: 'get'
  });
};

export interface CategoryList {
  /**
   * 主键
   */
  id?: number;

  /**
   * 名称
   */
  name?: string;

  /**
   * 父类id
   */
  parentId?: number;

  /**
   * 图片
   */
  url?: string;

  /**
   * 子集
   */
  children?: CategoryList[];

  /**
   * 产品集
   */
  goods?: CategoryList[];
}
export interface GoodsItem {
  /**
   * 主键
   */
  id?: number;

  /**
   * 名称
   */
  name?: string;

  /**
   * 介绍
   */
  desc?: string;

  /**
   * 图片
   */
  url?: string;

  /**
   * 价格
   */
  price?: number;
}
